package com.italicatab;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;

public class HomeScreen extends Activity implements OnClickListener {

	ImageView IV_PRODUCTS, IV_ABOUT_US, IV_CONTACT_US, IV_PROJECTS, IV_HOME;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.home_screen);
		init();

	}

	private void init() {
		IV_PRODUCTS = (ImageView) findViewById(R.id.iv_products);
		IV_PRODUCTS.setOnClickListener(this);
		IV_ABOUT_US = (ImageView) findViewById(R.id.iv_about_us);
		IV_ABOUT_US.setOnClickListener(this);
		IV_CONTACT_US = (ImageView) findViewById(R.id.iv_con_us);
		IV_CONTACT_US.setOnClickListener(this);
		IV_HOME = (ImageView) findViewById(R.id.iv_home);
		IV_HOME.setOnClickListener(this);
		IV_PROJECTS = (ImageView) findViewById(R.id.iv_projects);
		IV_PROJECTS.setOnClickListener(this);

	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		System.gc();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.home_screen, menu);
		return true;
	}

	private void animatedStartActivity() {
		// we only animateOut this activity here.
		// The new activity will animateIn from its onResume() - be sure to
		// implement it.
		final Intent intent = new Intent(getApplicationContext(), Product.class);
		// disable default animation for new intent
		intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
		ActivitySwitcher.animationOut(findViewById(R.id.container),
				getWindowManager(),
				new ActivitySwitcher.AnimationFinishedListener() {
					@Override
					public void onAnimationFinished() {
						startActivity(intent);
						System.gc();
					}
				});
	}

	@Override
	public void onClick(View v) {
		if (v == IV_PRODUCTS) {
			animatedStartActivity();
		} else if (v == IV_ABOUT_US) {
			Intent i = new Intent(getApplicationContext(), AboutUs.class);
			startActivity(i);
		} else if (v == IV_CONTACT_US) {
			Intent i = new Intent(getApplicationContext(), ContactUs.class);
			startActivity(i);
		} else if (v == IV_HOME) {
			Intent i = new Intent(getApplicationContext(), Concept.class);
			startActivity(i);
		} else if (v == IV_PROJECTS) {
			Intent i = new Intent(getApplicationContext(), Projects.class);
			startActivity(i);
		}

	}
}
